package com.pojo;

import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Random;

public class Order {
    private Integer oId;

    //    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 可能会有时区错误

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date oDate; //请求指定格式，输出JSON的时候指定日期格式

    private Integer tId;

    private String oStatus;

    private BigDecimal oTotalMoney;

    private Integer oTotalNum;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date oPayoffDate;

    private String oSerialNo;

    private Integer dinerNum;  //用餐人数

    //自定义的table对象，逆向工程不能生成，需要自己写set和get方法
    private Table table;

    //根据需求有订单明细表,自己添加
    private List<OrderItem> orderItems;

    //默认构造方法, 初始化创建日期和订单流水号
    public Order(){
        this.oDate = new Date();
        Random random = new Random();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        this.oSerialNo = "west-"+ simpleDateFormat.format(new Date()) + random.nextInt(1000);

    }

    public List<OrderItem> getOrderItems() {
        return orderItems;
    }

    public void setOrderItems(List<OrderItem> orderItems) {
        this.orderItems = orderItems;
    }

    public void setTable(Table table) {
        this.table = table;
    }

    public Table getTable() {
        return table;
    }

    public Integer getoId() {
        return oId;
    }

    public void setoId(Integer oId) {
        this.oId = oId;
    }

    public Date getoDate() {
        return oDate;
    }

    public void setoDate(Date oDate) {
        this.oDate = oDate;
    }

    public Integer gettId() {
        return tId;
    }

    public void settId(Integer tId) {
        this.tId = tId;
    }

    public String getoStatus() {
        return oStatus;
    }

    public void setoStatus(String oStatus) {
        this.oStatus = oStatus == null ? null : oStatus.trim();
    }

    public BigDecimal getoTotalMoney() {
        return oTotalMoney;
    }

    public void setoTotalMoney(BigDecimal oTotalMoney) {
        this.oTotalMoney = oTotalMoney;
    }

    public Integer getoTotalNum() {
        return oTotalNum;
    }

    public void setoTotalNum(Integer oTotalNum) {
        this.oTotalNum = oTotalNum;
    }

    public Date getoPayoffDate() {
        return oPayoffDate;
    }

    public void setoPayoffDate(Date oPayoffDate) {
        this.oPayoffDate = oPayoffDate;
    }

    public String getoSerialNo() {
        return oSerialNo;
    }

    public void setoSerialNo(String oSerialNo) {
        this.oSerialNo = oSerialNo == null ? null : oSerialNo.trim();
    }

    public Integer getDinerNum() {
        return dinerNum;
    }

    public void setDinerNum(Integer dinerNum) {
        this.dinerNum = dinerNum;
    }
}